package com.hsy.sunflowerbao.common.ui

import com.flux.ui.activity.FSplashActivity
import com.hsy.sunflowerbao.R
import com.hsy.sunflowerbao.login.ui.LoginActivity
import com.hsy.sunflowerbao.utils.CommonUtils
import java.util.Timer
import android.os.Bundle
import com.gyf.barlibrary.ImmersionBar


/**
 * 开屏
 * Created on 2018/3/26.
 *
 * @author Yang
 */
class SplashActivity : FSplashActivity() {

    private val timer: Timer? = null

    override val splashContentView: Int
        get() = R.layout.activity_splash

    override val duration: Long
        get() = 3000

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        ImmersionBar.with(this)
                .statusBarColor(android.R.color.white)//设置状态栏颜色
                .statusBarDarkFont(true,0.15f)//设置状态栏文字颜色
                .init()
    }

    override fun onXGClick()= false

    override fun doInit()= false

    override fun doJump() {
        timer?.cancel()
        if (CommonUtils.checkLogin()) {
            startActivityWithTaskCleared(MainActivity::class.java)
        } else {
            startActivity(LoginActivity::class.java)
            finish()
        }
    }
}